﻿<title>库存</title>
<link type="text/css" href="${ctx}/resources/css/ace.min.1.css"  rel="stylesheet" />
<table>
<tr>
<th>商品单位:</th>
	<th width="70px;" class="label label-sm label-light arrowed"><a href="${ctx}/admin/stock/list${suffix}">不限</a></th>
	<#assign sTypes = dicSetting.getParameterMap("goods.unit")> 
	<#list sTypes?keys as key>
		<#if key_index lt 10>
			<th width="70px;" class="label label-sm label-warning arrowed"><a href="${ctx}/admin/stock/list${suffix}?label=${key}">${sTypes[key]}</a></th>
		</#if>
	</#list>
</tr>
<tr>
<tr>
<th>商品状态:</th>
<th width="70px;" class="label label-sm label-light arrowed"> <a href="${ctx}/admin/stock/list${suffix}" >不限</a> </th>
<th width="70px;" class="label label-sm label-success arrowed"> <a href="${ctx}/admin/stock/list${suffix}?state=1" >正常</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/stock/list${suffix}?state=2" >禁用</a> </th>
</tr>
</table>

<div class="hr hr-5"></div>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
			<table id="sample-table-1" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>商品名称</th>
						<th>商品原价(￥)</th>
						<th>商品折扣价(￥)</th>
						<th>商品图片</th>
						<#if amounts ??>
							<th>库存总数（<i style="color:red">${amounts!}</i>）</th>
						<#else>
							<th>库存总数</th>
						</#if>
						
						
						<th>商品单位</th>
						<th>仓库</th>
						<th>最近入库时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#list pager.itemList as u>
					<tr>
						<td>${u.id}</td>
						<td>
							<a title="点击商品名称,可以查看库存分布情况." href="${ctx}/admin/stock/list?goodsId=${u.goodsId}" >${u.goodsName!}</a>
						</td>
						<td>${u.goodsOldPrice!}</td>
						<td>${u.goodsDisPrice!}</td>
						<td>
							<#list gsonUtils.getImgsJsonList(u.goodsUrlList) as url>
							<span class="profile-picture">
								<img style="height:105px;width:250px;" class="editable img-responsive" src="${tagUtils.getFileFullPath(url)}" />
							</span>
							<#break>
							</#list>
						</td>
						<td>
						<#if u.amount == 0>
							缺货
						<#else>
							${u.amount!}
						</#if>
						</td>
						<td >
							<#if u.unit == 0>
							<#else>
								<span class="label label-sm label-warning arrowed">
									${dicSetting.getParameterValue("goods.unit." + u.unit)!}
								</span>
							</#if>
						</td>
						<td>
							<#if u.relativeId == 0>
								<a title="点击小区名称,可以查看小区库存分布情况." href="${ctx}/admin/stock/list?relativeId=${u.relativeId}" >平台</a>
							<#else>
								<@device cmd="get_estate_list">
									<#list estateList as o>
									<#if o.id == u.relativeId>
									<a title="点击小区名称,可以查看小区库存分布情况." href="${ctx}/admin/stock/list?relativeId=${u.relativeId}" >${o.name!}</a>
									</#if>
									</#list>
								</@device>
							</#if>
						</td>
						<td>
							<#if u.modifyTime??>
								${tagUtils.formatDate(u.modifyTime)!}
							<#else>
							${tagUtils.formatDate(u.createTime)!}
							</#if>
						</td>
						<td>
						<#if u.state == 2>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doState(this,'${u.id}');" id="off_state"/>
							<span class="lbl"></span>
						<#else>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doState(this,'${u.id}');" checked="checked" id="off_state"/>
							<span class="lbl"></span>
						</#if>
						</td>
						
						<td>
						</td>
					</tr>
				</#list>
				</tbody>
			</table>
		</div>
	
		<div class="hr hr-18 dotted hr-double"></div>
		<@h.page pager=pager action="${ctx}/admin/stock/list${suffix}" />
	</div><!-- /span -->
</div><!-- /row -->

<#if errorMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer red"></i>
		<span class="pink">${errorMsg!}</span>
	</h4>
</#if>

<#if infoMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer green"></i>
		<span class="pink">${infoMsg}</span>
	</h4>
</#if>

<script>
function isDel(url){
		if(!confirm("确认要删除？")){ 
				return false;		
		}else{
			location.href = url;
		}
	}
function doState(checkbox,id) {
		if(checkbox.checked) {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/stock/on?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		} else {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/stock/off?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		}
	}
$(document).ready(function(){
	RP.addBreadcrumb([ {name:"库存列表", active: true}]);
});
</script>